package fudan.se.project.util.http;

import fudan.se.project.controller.response.BaseResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ResponseWrapperUtil {

    public ResponseEntity<?> buildResponseBody(Map<String, String> response, HttpStatus status) {
        ResponseEntity.BodyBuilder builder = ResponseEntity.status(status);
        return builder.body(response);
    }

    public <T> ResponseEntity<T> buildResponseBody(T response, HttpStatus status) {
        ResponseEntity.BodyBuilder builder = ResponseEntity.status(status);
        return builder.body(response);
    }

    public ResponseEntity<BaseResponse> buildBaseResponseBody(String message, HttpStatus status) {
        ResponseEntity.BodyBuilder builder = ResponseEntity.status(status);
        return builder.body(new BaseResponse(message));
    }
}
